//package com.jinsi.controller;
//
//import com.jinsi.utils.PdfUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Controller
//@RequestMapping(value = "/pdf")
//public class PdfController {
//    /**
//     * 功能：pdf预览、下载
//     *
//     */
//    @Autowired
//    private FreeMarkerConfigurer configurer;
//
//    /**
//     * pdf预览
//     *
//     * @param request  HttpServletRequest
//     * @param response HttpServletResponse
//     */
//    @RequestMapping(value = "/preview")
//    public void preview(HttpServletRequest request, HttpServletResponse response) {
//        // 构造freemarker模板引擎参数,listVars.size()个数对应pdf页数
//        List<Map<String,Object>> listVars = new ArrayList<>();
//        Map<String,Object> variables = new HashMap<>();
//        variables.put("title","测试预览ASGX!");
//        listVars.add(variables);
//
//        PdfUtils.preview(configurer,"pdf.ftl",listVars,response);
//    }
//
//    /**
//     * pdf下载
//     *
//     * @param request  HttpServletRequest
//     * @param response HttpServletResponse
//     */
//    @RequestMapping(value = "/download")
//    public void download(HttpServletRequest request, HttpServletResponse response) {
//        List<Map<String,Object>> listVars = new ArrayList<>();
//        Map<String,Object> variables = new HashMap<>();
//        variables.put("title","测试下载ASGX!");
//        listVars.add(variables);
//        PdfUtils.download(configurer,"pdf.ftl",listVars,response,"测试中文.pdf");
//    }
//}
